#ifndef ABSTRACTPACKET_H
#define ABSTRACTPACKET_H

#include <QString>

#include "core/Node.h"

enum PacketType {
    JOIN_REQUEST,
    JOIN_RESPONSE,
    JOIN_INFO,
    BUSY,
    PAINT,
    MUTUAL_EXCL_TOKEN
};

class AbstractPacket
{
public:
    virtual PacketType getPacketType() const = 0;

    const QString & getSenderId() const { return senderId; }
    void setSenderId(QString senderId) { this->senderId = senderId; }

    const QString & getReceiverAddress() const { return receiverAddress; }
    quint16 getReceiverPort() const { return receiverPort; }

    void setReceiver(const QString & address, quint16 port) { this->receiverAddress = address; this->receiverPort = port; }
    void setReceiver(const Node * node) { this->receiverAddress = node->getAddress(); this->receiverPort = node->getPort(); }

private:
    QString senderId;
    QString receiverAddress;
    quint16 receiverPort;
};

#endif // ABSTRACTPACKET_H
